import request from '@/utils/request'

// 查询订单列表
export function listSimpleOrder (query) {
  return request({
    url: '/order/order',
    method: 'get',
    params: query
  })
}

// /dev-api/order/order  获取订单简要信息
export function getOrderInfos (id) {
  return request({
    url: `/order/order/${id}/simple`,
    method: 'get',
  })
}

// 获取订单出库单信息 /dev-api/order/order/{orderId}/outboundOrder
export function getOrderIssueInfos (orderId) {
  return request({
    url: `/order/order/${orderId}/outboundOrder`,
    method: 'get',
  })
}

// 取消订单
export function cancelOrder (orderId, data) {
  return request({
    url: '/order/order/' + orderId + '/cancel',
    method: 'put',
    data: data
  })
}

//   修改订单状态
export function updOrderStatus (id, data) {
  return request({
    url: `/order/order/${id}/orderStatus`,
    method: 'put',
    data: data
  })
}


// 修改订单状态为已支付
export function updOrderPayed (id, data) {
  return request({
    url: `/order/order/${id}/orderStatus/paid`,
    method: 'put',
    data: data
  })
}

// 获取支付方式
export function getPayList () {
  return request({
    url: '/payment/method/list',
    method: 'get'
  })
}

//  修改订单状态为未支付
export function updUnpay (id, data) {
  return request({
    url: `/order/order/${id}/orderStatus/unpaid`,
    method: 'put',
    data: data
  })
}

//  修改订单状态为已支付
export function updPay (id, data) {
  return request({
    url: `/order/order/${id}/orderStatus/paid`,
    method: 'put',
    data: data
  })
}

// 获取物流列表
export function getLogisticsList () {
  return request({
    url: '/logistics/logistics',
    method: 'get'
  })
}
// 获取物流列表
export function getLogisticsTraces (id) {
  return request({
    url: '/order/order/' + id + '/traces',
    method: 'get'
  })
}
// 修改订单物流单号
export function updLogistics (id, data) {
  return request({
    url: `/order/order/${id}/logistics`,
    method: 'put',
    data: data
  })
}
// 修改订单推荐人
export function updatePromotePhoneNumber (sn, data) {
  return request({
    url: `/order/order/${sn}/promotePhoneNumber`,
    method: 'put',
    data: data
  })
}

//隐藏订单
export function hideOrder(sn){
  return request({
    url: `/order/order/${sn}/invalid`,
    method: 'delete'
  })
}

//保留订单
export function keepOrder(sn ,data){
  return request({
    url: `/order/order/${sn}/createTime`,
    method: 'put',
    data: data
  })
}

//更换订单客户
export function changePurchaser(sn ,data){
  return request({
    url: `/order/order/${sn}/purchaser`,
    method: 'put',
    data: data
  })
}

//修改订单内部状态
export function updateInnerStatus(sn, data){
  return request({
    url: `/order/order/receive/${sn}/innerStatus`,
    method: 'put',
    data: data
  })
}

//修改订单发票开具
export function invoicable(sn, receipt){
  return request({
    url: `/order/order/${sn}/receipt`,
    method: 'put',
    data: {
      receipt: receipt
    }
  })
}

//添加赠品
export function addPresents(sn, presents){
  return request({
    url: `/order/orderItem/${sn}/presents`,
    method: 'post',
    data: presents
  })
}

//   修改运费
export function updFreightPrice (id, data) {
  return request({
    url: `/order/order/${id}/freightPrice`,
    method: 'put',
    data: data
  })
}
